package com.app.ryjy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 社会保险状态枚举
 */
@AllArgsConstructor
@Getter
public enum SocialInsuranceStatusEnum {
    // 在职参保
    ON_JOB_INSURED("在职参保", 1, -1),
    // 离退休
    RETIRED("离退休", 2, -1),
    // 享受一次性待遇的退休
    ONE_TIME_BENEFIT_RETIRED("享受一次性待遇的退休", 3, -1),
    // 终止保险关系
    TERMINATE_INSURANCE_RELATION("终止保险关系", 4, -1);

    private final String desc;
    private final int code;
    private final int bizCode;

    /**
     * 根据 bizCode 获取 code
     *
     * @param bizCode bizCode
     * @return code
     */
    public static int getCodeByBizCode(int bizCode) {
        for (SocialInsuranceStatusEnum status : values()) {
            if (status.getBizCode() == bizCode) {
                return status.getCode();
            }
        }
        throw new RuntimeException("bizCode 不存在");
    }

    public static void main(String[] args) {
        System.out.println(SocialInsuranceStatusEnum.getCodeByBizCode(1));
    }
}